import { service as request } from '@/utils/request'

/**
 * 分页查询公司
 * @param {*} data 
 * @returns 
 */
export function getList (data) {
  return request({
    url: `/hawk/company/search/${data.page.current}/${data.page.size}`,
    method: 'get',
    params: {
      name: data.query.company,
      areaId: data.query.areaId
    }
  })
}


/**
 * 判断同一地区的公司名，是否存在
 * @param {*} data 
 * @returns 
 */
export function isNameHave (cName,areaId) {
  return request({
    url: `/hawk/company/exists`,
    method: 'get',
    params: {
      name: cName,
      areaId:areaId
    }
  })
}





export function searchList (data) {
  return request({
    url: `/assets/dictionaries/cmdbCompany/page/${JSON.stringify(data)}`,
    method: 'get'
  })
}


export function doAddCompany (data) {
  return request({
    url: '/hawk/company/save',
    method: 'post',
    data
  })
}
/**
 * 
 * @param {*} data 
 * @returns 
 */
export function doEdit (data) {
  return request({
    url: '/hawk/company/update',
    method: 'put',
    data
  })
}
/**
 * 
 * @param {*} id 
 * @returns 
 */
export function doDelete (ids) {
  return request({
    url: `/hawk/company/del`,
    method: 'delete',
    data: ids,
  })
}
// header: {
//   'Content-Type': 'application/json;charset=UTF-8'
// }
export function getOne (id) {
  return request({
    url: `/assets/dictionaries/cmdbCompany/id/${id}`,
    method: 'get'
  })
}

/**
 * 获得所有的公司 
 * @returns 
 */
export function getAllCompany () {
  return request({
    url: `/hawk/company/get/all`,
    method: 'get'
  })
}

/**
 * 获得某一地区的公司
 * @param {*} id 
 * @returns 
 */
export function getComByAreaId (areaId) {
  return request({
    url: `/hawk/company/get/area/${areaId}`,
    method: 'get'
  })
}

/***
 * 查询公司下的所有部门
 */
export function getDepartmentsByCompayId (id) {
  return request({
    url: `/hawk/company/get/department/${id}`,
    method: 'get'
  })
}